package com.eddie.juc;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Eddie
 * @date 2022/08/17 10:34
 **/
public class IThreadPool extends ThreadPoolExecutor {
    private IThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
    }

    private static volatile IThreadPool instance;

    public static IThreadPool getInstance() {
        if (instance == null) {
            synchronized (IThreadPool.class) {
                if (instance == null) {
                    instance = new IThreadPool(5
                            ,20
                            ,300
                            ,TimeUnit.MINUTES
                            ,new ArrayBlockingQueue<>(20));
                }
            }
        }
        return instance;

    }
}
